 
 #This file produces Figure S4 in the Supplemental Appendix
 
 setwd("/Users/bsjjones/Dropbox/JoestenJones/PB R&R")

library(foreign)
library(rmeta)
library(plotrix)

####THIS SCRIPT GIVES ROBUSTNESS CHECKS#####

#####New Destination Sequential Analysis########


newdest<-read.csv("interactionNEWDEST.csv")
attach(newdest)
pdf("figureS4_Rplot.pdf")
par(mfrow=c(1,1),oma=c(0,0,2,0))
par(mar=c(3, 8, 1, 1))


coef.vec<-coeff
se.vec<-se
y.axis<-c(length(coef.vec):1)
var.names<-State
emph<-seq(0, 4, 1)

plot(coef.vec, y.axis, type = "p", axes = F, xlab = "Log-Odds Estimates", ylab = "", pch = 20, cex = .65, xlim = c(-1,12), xaxs = "r", main = " Alternative Measures and Subsamples", cex.main=.95, cex.lab=.85, mgp=c(2,.7,0)) 
#plot coefficients as points, turning off axes and labels. 

#set limits of x-axis so that they include mins and maxs of 
#coefficients + .95% confidence intervals and plot is symmetric; use "internal axes", and leave plot title empty
#the 3 lines below create horiztonal lines for 95% confidence intervals, and vertical ticks for 90% intervals

segments(coef.vec-qnorm(.975)*se.vec, y.axis, coef.vec+qnorm(.975)*se.vec, y.axis, lwd =  1, lend="butt")

#coef +/-1.96*se = 95% interval, lwd adjusts line thickness
#if you want to add tick marks for 90% confidence interval, use following 2 lines:
#segments(coef.vec-qnorm(.95)*se.vec, y.axis -.1, coef.vec-qnorm(.95)*se.vec, y.axis +.1, lwd = 1.1)#coef +/-1.64*se = 90% interval
#segments(coef.vec+qnorm(.95)*se.vec, y.axis -.1, coef.vec+qnorm(.95)*se.vec, y.axis +.1, lwd = 1.1)

axis(1, at = seq(-2,12,by=2), labels = NA, tick = T,#draw x-axis and labels with tick marks
    cex.axis = .55, mgp = c(2,.7,0))#reduce label size, moves labels closer to tick marks
axis(1, at = seq(-2,12,by=2), labels =  c( -2,  0, 2, 4, 6, 8, 10, 12), tick = T,#draw x-axis and labels with tick marks
    cex.axis = .55, mgp = c(2,.7,0))#reduce label size, moves labels closer to tick marks    

axis(2, at = y.axis, label = var.names,   las = 1, tick = F ,mgp = c(2,.6,0),
    cex.axis = .65) #draw y-axis with tick marks, make labels perpendicular to axis and closer to axis
segments(0,0,0,18,lty=2) # draw dotted line through 0
box(bty = "l") #place box around plot
x.height <- .20
box()
rm(list=ls())
detach(newdest)

dev.off()
